#include "MPI_TopoCart2D.h"


void MPI_TopoCart2D::init() {
    MPI_Comm_size(MPI_COMM_WORLD, &(this->comm_siz));
    MPI_Comm_rank(MPI_COMM_WORLD, &(this->proc_id));
}


void MPI_TopoCart2D::get_self_loc() {
    BLK_LOC_Y = proc_id % NUM_BLK_Y;
    BLK_LOC_Z = proc_id / NUM_BLK_Y;
}


void MPI_TopoCart2D::get_neighbors() {
    if(BLK_LOC_Y != 0)
        NBR_YN = proc_id - 1;
    else
        NBR_YN = MPI_PROC_NULL;

    if(BLK_LOC_Y != NUM_BLK_Y - 1)
        NBR_YP = proc_id + 1;
    else
        NBR_YP = MPI_PROC_NULL;

    if(BLK_LOC_Z != 0)
        NBR_ZN = proc_id - NUM_BLK_Y;
    else
        NBR_ZN = MPI_PROC_NULL;

    if(BLK_LOC_Z != NUM_BLK_Z - 1)
        NBR_ZP = proc_id + NUM_BLK_Y;
    else
        NBR_ZP = MPI_PROC_NULL;
}


void MPI_TopoCart2D::free() {

}
